import { unitType } from "/utils/dictionary";
const app = getApp();

Component({
  mixins: [],
  data: {
    permissions: [],
    unitType
  },
  props: {
    selectedServices: [],
    onEmit: () => { }
  },
  didMount() {
    this.setData({
      permissions: app.globalData.permissions
    });
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    onCreate() {
      this.props.onEmit({
        form: {
          freeServiceType: "BUY",
          serviceIndex: null,
          name: null,
          count: "",
          freeServiceId: null
        },
        index: null
      })
    },
    onModify(e) {
      this.props.onEmit({
        form: { ...this.props.selectedServices[e.target.dataset.index] },
        index: e.target.dataset.index
      })
    },
    onRemove(e) {
      this.props.onEmit({
        form: null,
        index: e.target.dataset.index
      })
    }
  },
});
